home *** CD-ROM | disk | FTP | other *** search
Modula Implementation | 1993-11-04 | 9.1 KB | 288 lines |
- (* ReqSupport.mod ported to M2Amiga 4.0 1991 by Jürgen Zimmermann *)
- (* Hilfsroutinen der Oberon-Implementation *)
- (* Req.mod ported to Oberon 1990 by Achim Siebert *)
- (* reqlibrary.h © 1988/1989 reserved by Colin Fox and Bruce Dawson *)
- (* changed 16.10.92 by Stefan Koehle *)
-
- (**********************************************************************
-
- :Program. FileRequester.mod
- :Contents. Einfaches Interface zum FileRequester der "req.library"
- :Author. Jürgen Zimmermann [JnZ]
- :Address. Ringstraße 6, W-6719 Altleiningen, Germany
- :Phone. 06356/1456
- :Copyright. Public Domain (but donation is always welcome!)
- :Language. Modula-2
- :Translator. M2Amiga AMSoft V4.096d
- :Imports. Die Prozedur "GetPathFromLock" habe ich aus dem Modul
- :Imports. "Disky" von Kai Bolay entnommen und an die Anforderungen
- :Imports. in diesem Interface angepaßt.
- :Imports. Die "req.library" muß im Verzeichnis "LIBS:" stehen!
- :History. V1.0 [JnZ] 25.May.1991 first internal version which works
- **********************************************************************)
-
-
-
-
- IMPLEMENTATION MODULE ReqSupport;
-
- IMPORT rd: ReqD,
- rl: ReqL;
-
- IMPORT Arts, DosD, DosL, DosSupport, ExecL, ExecD, IntuitionD,
- String, SYSTEM, WorkbenchD;
- FROM Arts IMPORT Terminate ;
- FROM SYSTEM IMPORT ADR,ADDRESS ;
- FROM InOut IMPORT WriteString,WriteLn ;
- FROM GraphicsD IMPORT ViewModes ;
-
- VAR result: INTEGER ;
-
-
-
-
- PROCEDURE GetPathFromLock(VAR Path : ARRAY OF CHAR;
- ThisLockPtr: DosD.FileLockPtr);
- (* von irgendeiner PD-Disk aus 'C' in Modula-II übersetzt (Autor ???) [kai]*)
-
- VAR CurDirPtr : DosD.FileLockPtr;
- OldDirPtr : DosD.FileLockPtr;
- VolumeLen : INTEGER;
- FIBPtr : DosD.FileInfoBlockPtr;
-
- BEGIN
- Path[0]:=0C;
- CurDirPtr:=DosSupport.DupLock(ThisLockPtr);
- IF (CurDirPtr = NIL)
- THEN
- RETURN;
- END; (* IF *)
- FIBPtr := ExecL.AllocMem(SIZE(FIBPtr^),ExecD.MemReqSet{ExecD.memClear,
- ExecD.public}) ;
- IF (FIBPtr # NIL)
- THEN
- ExecL.Forbid;
- String.Copy(Path,CurDirPtr^.volume^.name^);
- ExecL.Permit;
- String.BStrToStr(Path);
- String.Concat(Path,":");
- VolumeLen:=String.Length(Path);
- WHILE (CurDirPtr # NIL) DO
- IF NOT(DosL.Examine(CurDirPtr,FIBPtr))
- THEN
- Path[0]:=0C;
- DosSupport.UnLock(CurDirPtr);
- CurDirPtr:=NIL;
- ELSE
- OldDirPtr:=CurDirPtr;
- CurDirPtr:=DosSupport.ParentDir(OldDirPtr);
- DosSupport.UnLock(OldDirPtr);
- IF (CurDirPtr # NIL)
- THEN
- IF (String.Length(Path) # VolumeLen)
- THEN
- String.Insert(Path,VolumeLen,"/");
- END; (* IF *)
- String.Insert(Path,VolumeLen,FIBPtr^.fileName);
- END; (* IF *)
- END; (* IF *)
- END; (* WHILE *)
- ExecL.FreeMem(FIBPtr,SIZE(FIBPtr^)) ;
- END; (* IF *)
- END GetPathFromLock;
-
-
-
- PROCEDURE FileRequest(RequesterWindow : IntuitionD.WindowPtr;
- load : BOOLEAN; (* FALSE means saving *)
- getPath : BOOLEAN;
- Title : ARRAY OF CHAR;
- VAR FileNamePath,
- FileName : ARRAY OF CHAR): BOOLEAN;
-
- VAR freq : rd.FileRequester;
- dirstring : rd.DirString;
- filestring: rd.FileString;
- wholefile : rd.PathString;
- pathPos : LONGINT;
- lock : DosD.FileLockPtr;
- msg : WorkbenchD.WBStartupPtr;
-
-
- BEGIN
- IF (String.Length(FileNamePath) # 0) THEN
- String.CopyPart(dirstring,FileNamePath,0,130) ;
-
- ELSIF getPath THEN
- (* Arts unterstützt mich ab jetzt, d.h. ich setze den
- Pfad im Path-Gadget genau auf den Pfad, der beim Start des
- Programms vorgegeben ist: Dadurch kann man sich per "Parent"
- bis zur obersten Ebene hindurchhangeln, nicht wie bei dem
- Requester in "m2emacs"! *)
- IF (Arts.wbStarted) THEN
-
- msg:=Arts.startupMsg;
- lock:=msg^.argList^[0].lock;
- IF (lock # NIL) THEN
-
- GetPathFromLock(dirstring,lock);
- END; (* IF *)
- ELSE
-
- GetPathFromLock(dirstring,Arts.oldCurrentDir);
- END; (* IF *)
- END; (* IF *)
-
- String.CopyPart(filestring,FileName,0,30) ;
-
- WITH freq DO
- versionNumber :=0;
- title :=SYSTEM.ADR(Title);
- dir :=SYSTEM.ADR(dirstring);
- file :=SYSTEM.ADR(filestring);
- pathName :=SYSTEM.ADR(wholefile);
- flags :=SYSTEM.LONGSET{rd.infogadget,rd.caching};
- window :=RequesterWindow;
- maxExtendedSelect:=0;
- numcolumns :=30; (* Anzahl der angezeigten Zeichen der Files! *)
- devcolumns :=15;
- flags :=SYSTEM.LONGSET{};
-
- IF load
- THEN
- INCL(flags,rd.loading);
- ELSE
- INCL(flags,rd.saving);
- END; (* IF *)
-
-
- IF (RequesterWindow # NIL) AND (* Eigener Screen mit 2 Farben *)
- (RequesterWindow^.wScreen^.bitMap.depth < 2) THEN
-
- IF (lace IN RequesterWindow^.wScreen^.viewPort.modes) THEN
- numlines :=40; (* Anzahl der sichtbaren Files *)
- ELSE
- numlines :=20;
- END ;
- dirnamescolor :=1; (* Farben fuer zweifarbigen Screen *)
- devicenamescolor :=1;
- detailcolor :=0;
- blockcolor :=1;
- gadgettextcolor :=1;
- textmessagecolor :=1;
- stringnamecolor :=1;
- stringgadgetcolor:=1;
- boxbordercolor :=1;
- gadgetboxcolor :=1;
- ELSE (* Workbenchscreen oder eigener mit mehr Farben *)
- numlines :=20; (* Anzahl der sichtbaren Files *)
- dirnamescolor :=3;
- devicenamescolor :=2;
- detailcolor :=0;
- blockcolor :=1;
- gadgettextcolor :=1;
- textmessagecolor :=3;
- stringnamecolor :=1;
- stringgadgetcolor:=2;
- boxbordercolor :=3;
- gadgetboxcolor :=3;
-
- END ;
-
- windowLeftEdge :=0;
- windowTopEdge :=0;
- show :="*";
- hide :="";
- END; (* WITH *)
-
- IF rl.FileRequest(SYSTEM.ADR(freq)) THEN
- IF String.Length(wholefile) # 0 THEN
- pathPos := String.LastPos(wholefile,MAX(LONGCARD),"/") ;
-
- IF pathPos # String.noOccur THEN
- String.CopyPart(FileNamePath,wholefile,0,pathPos) ;
- String.CopyPart(FileName,wholefile,(pathPos+1),
- (String.Length(wholefile)-pathPos)) ;
- ELSE
- pathPos := String.LastPos(wholefile,MAX(LONGCARD),":") ;
- IF pathPos # String.noOccur THEN
- String.CopyPart(FileNamePath,wholefile,0,pathPos+1) ;
- String.CopyPart(FileName,wholefile,(pathPos+1),
- (String.Length(wholefile)-pathPos)) ;
- ELSE
- String.Copy(FileName,wholefile) ;
- FileNamePath[0] := 0C ;
- END ;
-
- END ;
- END ;
-
- RETURN(TRUE);
- ELSE
- RETURN(FALSE);
- END; (* IF *)
- END FileRequest;
-
-
- PROCEDURE Request(header,body,posText,midText,negText: ADDRESS): INTEGER ;
-
- VAR textR : rd.TRStructure;
-
- BEGIN
- textR.text := body; (* Text *)
- textR.controls := NIL;
- textR.window := NIL;
- textR.middleText := midText; (* mitte *)
- textR.positiveText := posText; (* links *)
- textR.negativeText := negText; (* rechts *)
- textR.title := header; (* FensterTitel *)
- textR.keyMask := {0..15};
- textR.textcolor := 1;
- textR.detailcolor := 0;
- textR.blockcolor := 0;
- textR.versionnumber := 0;
- textR.rfu1 := 0;
- textR.rfu2 := 0;
- result:=rl.TextRequest(ADR(textR));
- RETURN(result);
- END Request;
-
-
- PROCEDURE ThreeGadRequest(header,body,posText,midText,negText:
- ARRAY OF CHAR): INTEGER ;
- BEGIN
- RETURN Request(ADR(header),ADR(body),ADR(posText),ADR(midText),
- ADR(negText)) ;
- END ThreeGadRequest ;
-
-
- PROCEDURE SimpleRequest(header,body,posText : ARRAY OF CHAR);
-
- BEGIN
- result := Request(ADR(header),ADR(body),ADR(posText),NIL,NIL);
- END SimpleRequest;
-
-
- PROCEDURE DeadEndExit(header,body,posText: ARRAY OF CHAR) ;
-
- BEGIN
- result := Request(ADR(header),ADR(body),ADR(posText),NIL,NIL) ;
- Terminate ;
- END DeadEndExit ;
-
-
- PROCEDURE TwoGadRequest(header,body,posText,negText : ARRAY OF CHAR):
- BOOLEAN;
-
- BEGIN
- result := Request(ADR(header),ADR(body),ADR(posText),NIL,ADR(negText));
- IF result = 1 THEN
- RETURN TRUE
- ELSE
- RETURN FALSE
- END ;
- END TwoGadRequest;
-
-
- END ReqSupport.
-